package br.ufmg.dcc.simulesspl.view;

import java.util.List;
import java.util.Scanner;

import br.ufmg.dcc.simulesspl.exception.InvalidSelectionException;
import br.ufmg.dcc.simulesspl.model.EngineerCard;
import br.ufmg.dcc.simulesspl.model.EngineerSelection;

public class EngineerSelectionView extends AbstractView {

	private EngineerSelection engineerSelection = new EngineerSelection();

	public void chooseEngineers() throws InvalidSelectionException {
		Scanner scanner = new Scanner(System.in);

		String command = scanner.nextLine();
		engineerSelection.select(command);

		getGameBoard().getCurrentSprint().setDeveloper(engineerSelection.getSelectedDeveloper());
		getGameBoard().getCurrentSprint().setBugFixer(engineerSelection.getSelectedBugFixer());
	}

	public void showInvalidEngineerMessage() {
		System.out.println(i18n().str("(Invaid Developers)"));
		System.out.println();
	}

	public void showEngineers() {
		List<EngineerCard> projects = engineerSelection.getEngineerOptions();

		System.out.println(i18n().str("Select the developer for this sprint"));
		for (int i = 0; i < projects.size(); i++) {
			System.out.println(String.format("%s %d: %s", i18n().str("Developer"), i + 1, new EngineerCardView(projects.get(i)).toString()));
		}
		System.out.println();
		System.out.println(i18n().str("Your choice") + ": ");
	}
}
